package cn.itsource.order.controller;

import cn.itsource.basic.util.AxajResult;
import cn.itsource.basic.util.SystemLoginInfo;

import cn.itsource.order.service.IProductOrderService;
import cn.itsource.user.domain.LoginInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@RestController
@RequestMapping("/productOrder")
public class ProductOrderController {
    @Autowired
    private IProductOrderService productOrderService;

    /**
     * 提交服务订单
     * @param map
     * @return
     */
    @PostMapping("/submitOrder")
    public AxajResult submitOrder(@RequestBody Map<String,Object> map, HttpServletRequest request){
        try {
            //获取登录信息对象
            LoginInfo loginInfo = SystemLoginInfo.get(request);
            //提交服务订单
            productOrderService.submitOrder(map,loginInfo);
            return new AxajResult();
        } catch (Exception e) {
            e.printStackTrace();
            return new AxajResult(false, e.getMessage());
        }
    }
}
